home *** CD-ROM | disk | FTP | other *** search
/ Young Minds / Young Minds Interactive CD-ROM.ISO / umoria / wizard.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-07-28  |  11.0 KB  |  381 lines

  1. #include <stdio.h>
  2.  
  3. #include "constants.h"
  4. #include "config.h"
  5. #include "types.h"
  6. #include "externs.h"
  7.  
  8. #ifdef USG
  9. #include <string.h>
  10. #else
  11. #include <strings.h>
  12. #endif
  13.  
  14. #ifdef sun   /* correct SUN stupidity in the stdio.h file */
  15. char *sprintf();
  16. #endif
  17.  
  18.  
  19. /* Print Moria credits                    -RAK-    */
  20. game_version()
  21. {
  22.   vtype tmp_str;
  23.  
  24.   clear_screen(0, 0);
  25.   (void) sprintf(tmp_str, "               Moria Version %f", CUR_VERSION);
  26.   put_buffer(tmp_str, 0, 0);
  27.   put_buffer("Version 0.1  : 03/25/83", 1, 0);
  28.   put_buffer("Version 1.0  : 05/01/84", 2, 0);
  29.   put_buffer("Version 2.0  : 07/10/84", 3, 0);
  30.   put_buffer("Version 3.0  : 11/20/84", 4, 0);
  31.   put_buffer("Version 4.0  : 01/20/85", 5, 0);
  32.   put_buffer("Modules :", 7, 0);
  33.   put_buffer("     V1.0  Dungeon Generator      - RAK", 8, 0);
  34.   put_buffer("           Character Generator    - RAK & JWT", 9, 0);
  35.   put_buffer("           Moria Module           - RAK", 10, 0);
  36.   put_buffer("           Miscellaneous          - RAK & JWT", 11, 0);
  37.   put_buffer("     V2.0  Town Level & Misc      - RAK", 12, 0);
  38.   put_buffer("     V3.0  Internal Help & Misc   - RAK", 13, 0);
  39.   put_buffer("     V4.0  Source Release Version - RAK", 14, 0);
  40.   put_buffer("Robert Alan Koeneke               Jimmey Wayne Todd Jr.", 16, 0);
  41.  put_buffer("Student/University of Oklahoma    Student/University of Oklahoma",
  42.         17, 0);
  43.   put_buffer("119 Crystal Bend                  1912 Tiffany Dr.", 18, 0);
  44.   put_buffer("Norman, OK 73069                  Norman, OK  73071", 19, 0);
  45.   put_buffer("(405)-321-2925                    (405) 360-6792", 20, 0);
  46.   pause_line(23);
  47.   clear_screen(0, 0);
  48.   put_buffer("UNIX MORIA Port by James E. Wilson", 2, 0);
  49.   put_buffer("                   wilson@ernie.Berkeley.EDU", 3, 0);
  50.   put_buffer("                   ucbvax!ucbernie!wilson", 4, 0);
  51.   put_buffer("This version is based on the VMS version 4.8", 6, 0);
  52.   put_buffer("but is no longer identical to the original VMS program.", 7, 0);
  53.   put_buffer("Please use care when referring to this program.", 8, 0);
  54.   put_buffer("Please call it 'umoria' or 'UNIX MORIA' or something", 9, 0);
  55.   put_buffer("similar to avoid confusion.", 10, 0);
  56.   pause_line(23);
  57.   draw_cave();
  58. }
  59.  
  60.  
  61. /* Light up the dungeon                    -RAK-    */
  62. wizard_light()
  63. {
  64.   register cave_type *c_ptr;
  65.   register int k, l, i, j;
  66.   int flag;
  67.  
  68.   if (cave[char_row][char_col].pl)
  69.     flag = FALSE;
  70.   else
  71.     flag = TRUE;
  72.   for (i = 0; i < cur_height; i++)
  73.     for (j = 0; j < cur_width; j++)
  74.       if (set_floor(cave[i][j].fval))
  75.     for (k = i-1; k <= i+1; k++)
  76.       for (l = j-1; l <= j+1; l++)
  77.         {
  78.           c_ptr = &cave[k][l];
  79.           c_ptr->pl = flag;
  80.           if (!flag)
  81.         c_ptr->fm = FALSE;
  82.         }
  83.   prt_map();
  84. }
  85.  
  86.  
  87. /* Wizard routine for gaining on stats            -RAK-    */
  88. change_character()
  89. {
  90.   int tmp_val;
  91.   vtype tmp_str;
  92.   register struct stats *s_ptr;
  93.   register struct misc *m_ptr;
  94.  
  95.   s_ptr = &py.stats;
  96.   prt("(3 - 118) Strength     == ", 0, 0);
  97.   (void) get_string(tmp_str, 0, 25, 10);
  98.   tmp_val = -999;
  99.   (void) sscanf(tmp_str, "%d", &tmp_val);
  100.   if ((tmp_val > 2) && (tmp_val < 119))
  101.     {
  102.       s_ptr->str  = tmp_val;
  103.       s_ptr->cstr = tmp_val;
  104.       prt_strength();
  105.     }
  106.   prt("(3 - 118) Intelligence == ", 0, 0);
  107.   (void) get_string(tmp_str, 0, 25, 10);
  108.   tmp_val = -999;
  109.   (void) sscanf(tmp_str, "%d", &tmp_val);
  110.   if ((tmp_val > 2) && (tmp_val < 119))
  111.     {
  112.       s_ptr->intel  = tmp_val;
  113.       s_ptr->cint = tmp_val;
  114.       prt_intelligence();
  115.     }
  116.   prt("(3 - 118) Wisdom       == ", 0, 0);
  117.   (void) get_string(tmp_str, 0, 25, 10);
  118.   tmp_val = -999;
  119.   (void) sscanf(tmp_str, "%d", &tmp_val);
  120.   if ((tmp_val > 2) && (tmp_val < 119))
  121.     {
  122.       s_ptr->wis  = tmp_val;
  123.       s_ptr->cwis = tmp_val;
  124.       prt_wisdom();
  125.     }
  126.   prt("(3 - 118) Dexterity    == ", 0, 0);
  127.   (void) get_string(tmp_str, 0, 25, 10);
  128.   tmp_val = -999;
  129.   (void) sscanf(tmp_str, "%d", &tmp_val);
  130.   if ((tmp_val > 2) && (tmp_val < 119))
  131.     {
  132.       s_ptr->dex  = tmp_val;
  133.       s_ptr->cdex = tmp_val;
  134.       prt_dexterity();
  135.     }
  136.   prt("(3 - 118) Constitution == ", 0, 0);
  137.   (void) get_string(tmp_str, 0, 25, 10);
  138.   tmp_val = -999;
  139.   (void) sscanf(tmp_str, "%d", &tmp_val);
  140.   if ((tmp_val > 2) && (tmp_val < 119))
  141.     {
  142.       s_ptr->con  = tmp_val;
  143.       s_ptr->ccon = tmp_val;
  144.       prt_constitution();
  145.     }
  146.   prt("(3 - 118) Charisma     == ", 0, 0);
  147.   (void) get_string(tmp_str, 0, 25, 10);
  148.   tmp_val = -999;
  149.   (void) sscanf(tmp_str, "%d", &tmp_val);
  150.   if ((tmp_val > 2) && (tmp_val < 119))
  151.     {
  152.       s_ptr->chr  = tmp_val;
  153.       s_ptr->cchr = tmp_val;
  154.       prt_charisma();
  155.     }
  156.  
  157.   m_ptr = &py.misc;
  158.   prt("(1 - 32767) Hit points == ", 0, 0);
  159.   (void) get_string(tmp_str, 0, 25, 10);
  160.   tmp_val = -1;
  161.   (void) sscanf(tmp_str, "%d", &tmp_val);
  162.   if ((tmp_val > 0) && (tmp_val < 32768))
  163.     {
  164.       m_ptr->mhp  = tmp_val;
  165.       m_ptr->chp  = (double)tmp_val;
  166.       prt_mhp();
  167.       prt_chp();
  168.     }
  169.   prt("(0 - 32767) Mana       == ", 0, 0);
  170.   (void) get_string(tmp_str, 0, 25, 10);
  171.   tmp_val = -999;
  172.   (void) sscanf(tmp_str, "%d", &tmp_val);
  173.   if ((tmp_val > -1) && (tmp_val < 32768))
  174.     {
  175.       m_ptr->mana  = tmp_val;
  176.       m_ptr->cmana = (double)tmp_val;
  177.       prt_cmana();
  178.     }
  179.   (void) sprintf(tmp_str, "Current==%d  (0-200) Searching == ", m_ptr->srh);
  180.   tmp_val = strlen(tmp_str);
  181.   prt(tmp_str, 0, 0);
  182.   (void) get_string(tmp_str, 0, tmp_val, 10);
  183.   tmp_val = -999;
  184.   (void) sscanf(tmp_str, "%d", &tmp_val);
  185.   if ((tmp_val > -1) && (tmp_val < 201))
  186.     m_ptr->srh  = tmp_val;
  187.   (void) sprintf(tmp_str, "Current==%d  (0-10) Stealth == ", m_ptr->stl);
  188.   tmp_val = strlen(tmp_str);
  189.   prt(tmp_str, 0, 0);
  190.   (void) get_string(tmp_str, 0, tmp_val, 10);
  191.   tmp_val = -999;
  192.   (void) sscanf(tmp_str, "%d", &tmp_val);
  193.   if ((tmp_val > -1) && (tmp_val < 11))
  194.     m_ptr->stl  = tmp_val;
  195.   (void) sprintf(tmp_str, "Current==%d  (0-200) Disarming == ", m_ptr->disarm);
  196.   tmp_val = strlen(tmp_str);
  197.   prt(tmp_str, 0, 0);
  198.   (void) get_string(tmp_str, 0, tmp_val, 10);
  199.   tmp_val = -999;
  200.   (void) sscanf(tmp_str, "%d", &tmp_val);
  201.   if ((tmp_val > -1) && (tmp_val < 201))
  202.     m_ptr->disarm = tmp_val;
  203.   (void) sprintf(tmp_str, "Current==%d  (0-100) Save == ", m_ptr->save);
  204.   tmp_val = strlen(tmp_str);
  205.   prt(tmp_str, 0, 0);
  206.   (void) get_string(tmp_str, 0, tmp_val, 10);
  207.   tmp_val = -999;
  208.   (void) sscanf(tmp_str, "%d", &tmp_val);
  209.   if ((tmp_val > -1) && (tmp_val < 201))
  210.     m_ptr->save = tmp_val;
  211.   (void) sprintf(tmp_str, "Current==%d  (0-200) Base to hit == ", m_ptr->bth);
  212.   tmp_val = strlen(tmp_str);
  213.   prt(tmp_str, 0, 0);
  214.   (void) get_string(tmp_str, 0, tmp_val, 10);
  215.   tmp_val = -999;
  216.   (void) sscanf(tmp_str, "%d", &tmp_val);
  217.   if ((tmp_val > -1) && (tmp_val < 201))
  218.     m_ptr->bth  = tmp_val;
  219.   (void) sprintf(tmp_str, "Current==%d  (0-200) Bows/Throwing == ",
  220.          m_ptr->bthb);
  221.   tmp_val = strlen(tmp_str);
  222.   prt(tmp_str, 0, 0);
  223.   (void) get_string(tmp_str, 0, tmp_val, 10);
  224.   tmp_val = -999;
  225.   (void) sscanf(tmp_str, "%d", &tmp_val);
  226.   if ((tmp_val > -1) && (tmp_val < 201))
  227.     m_ptr->bthb = tmp_val;
  228.   (void) sprintf(tmp_str, "Current==%d  Gold == ", m_ptr->au);
  229.   tmp_val = strlen(tmp_str);
  230.   prt(tmp_str, 0, 0);
  231.   (void) get_string(tmp_str, 0, tmp_val, 10);
  232.   tmp_val = -999;
  233.   (void) sscanf(tmp_str, "%d", &tmp_val);
  234.   if (tmp_val > -1)
  235.     {
  236.       m_ptr->au = tmp_val;
  237.       prt_gold();
  238.     }
  239.  
  240.   erase_line(MSG_LINE, 0);
  241.   py_bonuses(blank_treasure, 0);
  242. }
  243.  
  244.  
  245. /* Wizard routine for creating objects            -RAK-    */
  246. wizard_create()
  247. {
  248.   int tmp_val;
  249.   vtype tmp_str;
  250.   register int flag;
  251.   register treasure_type *i_ptr;
  252.   register cave_type *c_ptr;
  253.   char command;
  254.  
  255.   msg_print("Warning: This routine can cause fatal error.");
  256.   /* make sure player sees the message */
  257.   msg_print(" ");
  258.   msg_flag = FALSE;
  259.   i_ptr = &inventory[INVEN_MAX];
  260.   prt("Name   : ", 0, 0);
  261.   if (get_string(tmp_str, 0, 9, 80))
  262.     (void) strcpy(i_ptr->name, tmp_str);
  263.   else
  264.     (void) strcpy(i_ptr->name, "& Wizard Object!");
  265.   do
  266.     {
  267.       prt("Tval   : ", 0, 0);
  268.       (void) get_string(tmp_str, 0, 9, 10);
  269.       tmp_val = 0;
  270.       (void) sscanf(tmp_str, "%d", &tmp_val);
  271.       flag = TRUE;
  272.       switch(tmp_val)
  273.     {
  274.     case 1: case 13: case 15 :    i_ptr->tchar = '~'; break;
  275.     case 2:     i_ptr->tchar = '&'; break;
  276.     case 10:    i_ptr->tchar = '{'; break;
  277.     case 11:    i_ptr->tchar = '{'; break;
  278.     case 12:    i_ptr->tchar = '{'; break;
  279.     case 20:    i_ptr->tchar = '}'; break;
  280.     case 21:    i_ptr->tchar = '/'; break;
  281.     case 22:    i_ptr->tchar = '\\'; break;
  282.     case 23:    i_ptr->tchar = '|'; break;
  283.     case 25:    i_ptr->tchar = '\\'; break;
  284.     case 30:    i_ptr->tchar = ']'; break;
  285.     case 31:    i_ptr->tchar = ']'; break;
  286.     case 32:    i_ptr->tchar = '('; break;
  287.     case 33:    i_ptr->tchar = ']'; break;
  288.     case 34:    i_ptr->tchar = ')'; break;
  289.     case 35:    i_ptr->tchar = '['; break;
  290.     case 36:    i_ptr->tchar = '('; break;
  291.     case 40:    i_ptr->tchar = '\''; break;
  292.     case 45:    i_ptr->tchar = '='; break;
  293.     case 55:    i_ptr->tchar = '_'; break;
  294.     case 60:    i_ptr->tchar = '-'; break;
  295.     case 65:    i_ptr->tchar = '-'; break;
  296.     case 70: case 71:    i_ptr->tchar = '?'; break;
  297.     case 75: case 76: case 77:    i_ptr->tchar = '!'; break;
  298.     case 80:    i_ptr->tchar = ','; break;
  299.     case 90:    i_ptr->tchar = '?'; break;
  300.     case 91:    i_ptr->tchar = '?'; break;
  301.     default:    flag = FALSE; break;
  302.     }
  303.     }
  304.   while (!flag);
  305.   i_ptr->tval = tmp_val;
  306.   prt("Subval : ", 0, 0);
  307.   (void) get_string(tmp_str, 0, 9, 10);
  308.   tmp_val = 1;
  309.   (void) sscanf(tmp_str, "%d", &tmp_val);
  310.   i_ptr->subval = tmp_val;
  311.   prt("Weight : ", 0, 0);
  312.   (void) get_string(tmp_str, 0, 9, 10);
  313.   tmp_val = 1;
  314.   (void) sscanf(tmp_str, "%d", &tmp_val);
  315.   i_ptr->weight = tmp_val;
  316.   prt("Number : ", 0, 0);
  317.   (void) get_string(tmp_str, 0, 9, 10);
  318.   tmp_val = 1;
  319.   (void) sscanf(tmp_str, "%d", &tmp_val);
  320.   i_ptr->number = tmp_val;
  321.   prt("Damage : ", 0, 0);
  322.   (void) get_string(tmp_str, 0, 9, 5);
  323.   (void) strcpy(i_ptr->damage, tmp_str);
  324.   prt("+To hit: ", 0, 0);
  325.   (void) get_string(tmp_str, 0, 9, 10);
  326.   tmp_val = 0;
  327.   (void) sscanf(tmp_str, "%d", &tmp_val);
  328.   i_ptr->tohit = tmp_val;
  329.   prt("+To dam: ", 0, 0);
  330.   (void) get_string(tmp_str, 0, 9, 10);
  331.   tmp_val = 0;
  332.   (void) sscanf(tmp_str, "%d", &tmp_val);
  333.   i_ptr->todam = tmp_val;
  334.   prt("AC     : ", 0, 0);
  335.   (void) get_string(tmp_str, 0, 9, 10);
  336.   tmp_val = 0;
  337.   (void) sscanf(tmp_str, "%d", &tmp_val);
  338.   i_ptr->ac = tmp_val;
  339.   prt("+To AC : ", 0, 0);
  340.   (void) get_string(tmp_str, 0, 9, 10);
  341.   tmp_val = 0;
  342.   (void) sscanf(tmp_str, "%d", &tmp_val);
  343.   i_ptr->toac = tmp_val;
  344.   prt("P1     : ", 0, 0);
  345.   (void) get_string(tmp_str, 0, 9, 10);
  346.   tmp_val = 0;
  347.   (void) sscanf(tmp_str, "%d", &tmp_val);
  348.   i_ptr->p1 = tmp_val;
  349.   prt("Flags (In HEX): ", 0, 0);
  350.   i_ptr->flags = get_hex_value(0, 16, 8);
  351.   prt("Cost : ", 0, 0);
  352.   (void) get_string(tmp_str, 0, 9, 10);
  353.   tmp_val = 0;
  354.   (void) sscanf(tmp_str, "%d", &tmp_val);
  355.   i_ptr->cost = tmp_val;
  356.  
  357.   prt("Level : ", 0, 0);
  358.   (void) get_string(tmp_str, 0, 10, 10);
  359.   tmp_val = 0;
  360.   (void) sscanf(tmp_str, "%d", &tmp_val);
  361.   i_ptr->level = tmp_val;
  362.  
  363.   if (get_com("Allocate? (Y/N)", &command))
  364.     switch(command)
  365.       {
  366.       case 'y': case 'Y':
  367.     popt(&tmp_val);
  368.     t_list[tmp_val] = inventory[INVEN_MAX];
  369.     c_ptr = &cave[char_row][char_col];
  370.     if (c_ptr->tptr != 0)
  371.       (void) delete_object(char_row, char_col);
  372.     c_ptr->tptr = tmp_val;
  373.     msg_print("Allocated...");
  374.     break;
  375.       default:
  376.     msg_print("Aborted...");
  377.     break;
  378.       }
  379.   inventory[INVEN_MAX] = blank_treasure;
  380. }
  381.